/**
 * 
 */
package com.ztesoft.web.baseconfig.service;

import java.util.List;

import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.web.baseconfig.db.po.DmPlanPO;
import com.ztesoft.web.baseconfig.db.po.DmSrcTablePO;
import com.ztesoft.web.baseconfig.db.po.DmStrategyPO;
import com.ztesoft.web.baseconfig.db.po.DmTargetTablePO;

/**
 * <Description> <br>
 * 
 * @author codeCreater<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2014年11月11日 <br>
 * @since V1.0<br>
 * @see com.ztesoft.web.baseconfig.service <br>
 */

public interface IDmPlanService {

	DmPlanPO selectByPrimaryKey(Integer key) throws BaseAppException;

	List<DmPlanPO> selectByArg(DmPlanPO record) throws BaseAppException;

	Page<DmPlanPO> selectByArgAndPage(DmPlanPO record, Page<DmPlanPO> resultPage) throws BaseAppException;

	// 草稿箱查询
	Page<DmPlanPO> selectByArgAndPageDraft(DmPlanPO record, Page<DmPlanPO> resultPage) throws BaseAppException;

	// 计划维护查询
	Page<DmPlanPO> selectByArgAndPageMaint(DmPlanPO record, Page<DmPlanPO> resultPage) throws BaseAppException;

	/**
	 * @param record
	 * @return 0:状态为00X，返回报错;1:存在相同名称的计划，不可以新增;
	 * @throws BaseAppException
	 */
	DmPlanPO add(DmPlanPO record) throws BaseAppException, Exception;
	
	/**
	 * 保存草稿
	 * 
	 * @param dpPO
	 * @param dttPO
	 * @param dstPO
	 * @return
	 * @throws BaseAppException
	 */
	DmStrategyPO addOfDraft(DmPlanPO dpPO, DmTargetTablePO dttPO, DmSrcTablePO dstPO) throws BaseAppException, Exception;
	
	/**
	 * 保存整个计划，可能有多个策略
	 * 
	 * @param dpPO
	 * @return
	 * @throws BaseAppException
	 */
	int addAllStrategy(DmPlanPO dpPO) throws BaseAppException, Exception;
	
	/**
	 * 保存整个计划，只有一个策略
	 * 
	 * @param dpPO
	 * @param dttPO
	 * @param dstPO
	 * @return
	 * @throws BaseAppException
	 */
	int addAllOneStrategy(DmPlanPO dpPO, DmTargetTablePO dttPO, DmSrcTablePO dstPO) throws BaseAppException, Exception;

	int update(DmPlanPO record) throws BaseAppException;
	int upexpDate(DmPlanPO record) throws BaseAppException;

	int deleteAllPlanInfo(Integer dmPlanId) throws BaseAppException;
	
	int updateTo00X(Integer dmPlanId) throws BaseAppException;

	DmPlanPO updateDToA(Integer dmPlanId) throws BaseAppException;

	// 删除草稿箱，把状态改为00X
	int delete(Integer dmPlanId) throws BaseAppException;

	// 删除计划维护，把状态改为00X
	int deleteMaint(Integer dmPlanId) throws BaseAppException;

	// 删除计划维护，把状态改为00X-00T
	int deleteMaint00T(Integer dmPlanId) throws BaseAppException;

	/**
	 * 任务生成器扫描数据管理计划表(DM_PLAN)和数据管理计划和关系表(DM_PLAN_RELATION)，获取当前有效的计划和策略记录
	 * 
	 * @return List
	 * @throws BaseAppException
	 */
	List<DmPlanPO> selectByDmPlanAndGroupNbr() throws BaseAppException;

	DmPlanPO selectByExecType(String execType) throws BaseAppException;

	List<DmPlanPO> selectSourceByDmPlanId(Integer dmPlanId)throws BaseAppException;

	DmPlanPO selectOperTypeByDmPlanId(Integer dmPlanId)throws BaseAppException;

}
